using System;

namespace SCG.SolarVengeanceEngine.BrainInfo
{
    //Represents the information that brains have about StarSystems
    public class StarSystemInfo :SVObjectInfo
    {
        public StarSystemInfo(StarSystem sys)
            : base(sys)
        {
            _system = sys;
        }

        //Available properties

        //Is it visible?
        public bool Visible
        {
            get
            {
                if (!_system.VisibleTo.ContainsKey(Brain.ThisPlayer))
                    return false;
                return _system.VisibleTo[Brain.ThisPlayer];
            }
        }

        //Is it owned by the Brain?
        public bool OwnedByMe
        {
            get
            {
                return _system.Owner == Brain.ThisPlayer;
            }
        }

        //Bonus ship type
        public StarShipType BonusShipType
        {
            get
            {
                if (Visible)
                    return _system.BonusShipType;
                else
                    return StarShipType.WarShip;
            }
        }
        public double BonusValue
        {
            get
            {
                if (Visible)
                    return _system.BonusValue;
                else
                    return 0;
            }
        }

        //Capital?
        public bool IsCapital
        {
            get
            {
                if (Visible)
                    return _system.IsCapital;
                else
                    return false;
            }
        }

        //Was a Jumpgate created?
        public bool JumpGateCreated
        {
            get
            {
                if (OwnedByMe)
                    return _system.JumpGateCreated;
                else
                    return false;
            }
        }

        //Name
        public string Name
        {
            get
            {
                return _system.Name;
            }
        }

        //Name of Owner
        public string Owner
        {
            get
            {
                if (Visible)
                {
                    if (_system.Owner != null)
                        return _system.Owner.Name;
                    else
                        return "";
                }
                else
                    return "";
            }
        }

        //Index of owner
        public int OwnerInt
        {
            get
            {
                if (Visible)
                {
                    if (_system.Owner == null)
                        return -1;
                    else
                        return _system.Owner.Index;
                }
                else
                    return -1;
            }
        }

        //Resources
        public int Resources
        {
            get
            {
                if (Visible)
                    return _system.ResourcesInt;
                else
                    return 0;
            }
        }

        //Scanners and Shields
        public int Scanners
        {
            get
            {
                if (Visible)
                    return _system.Scanners;
                else
                    return 0;
            }
        }
        public int Shields
        {
            get
            {
                if (Visible)
                    return _system.Shields;
                else
                    return 0;
            }
        }

        //System's value
        public int Value
        {
            get
            {
                if (Visible)
                    return _system.Value;
                else
                    return 0;
            }
        }

        //Auto settings
        public bool AutoShields
        {
            get
            {
                if (OwnedByMe)
                    return _system.AutoShields;
                else
                    return false;
            }
        }
        public bool AutoScanners
        {
            get
            {
                if (OwnedByMe)
                    return _system.AutoScanners;
                else
                    return false;
            }
        }
        public bool AutoStarShip
        {
            get
            {
                if (OwnedByMe)
                    return _system.AutoStarShip;
                else
                    return false;
            }
        }
        public StarShipDescriptor AutoStarShipType
        {
            get
            {
                if (OwnedByMe)
                    return _system.AutoStarShipType;
                else
                    return new StarShipDescriptor(StarShipType.WarShip, 8, 4, false);
            }
        }
        
        //private members
        internal StarSystem _system;
    }
}
